package data;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Message extends Base implements Serializable {

	public static final String SeedName = "message";
	private static final long serialVersionUID = 1L;
	private static SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
	
	private int userId;
	private int delete;
	private int forumId;
	private int id;
	private String message;
	private String subject;
	private Date created_date;
	private String userName;

	public String getDatetimeString(){
		return sd.format(created_date);
	}
	
	@Override
	public String toString() {
		String msg=message;
		String user=userName;
		String sub=subject;
		if(sub.length()>20){
			sub=sub.substring(0, 20)+"...";
		}
		if(msg.length()>35){
			msg=msg.substring(0, 35)+"...";
		}
		
		return id + " "+user+ " ["+ subject + "] ["+msg+"] at:"+getDatetimeString();
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public int getDelete() {
		return delete;
	}

	public void setDelete(int delete) {
		this.delete = delete;
	}

	public int getForumId() {
		return forumId;
	}

	public void setForumId(int forumId) {
		this.forumId = forumId;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public Date getTime() {
		return created_date;
	}

	public void setTime(Date time) {
		this.created_date = time;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}
}
